package com.gexiaobao.pigeon.ui.adapter

import android.graphics.Paint
import androidx.appcompat.widget.AppCompatTextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.AppBaseListResponse
import com.gexiaobao.pigeon.databinding.ItemWatchRegistrationBinding

/**
 * @Author      : hxw
 * @Date        : 2024/6/21 16:55
 * @Describe    :
 */
class AdapterWatchRegistration(data: ArrayList<AppBaseListResponse.BaseListBean>) :
    BaseQuickAdapter<AppBaseListResponse.BaseListBean, DataBindBaseViewHolder>(R.layout.item_watch_registration, data) {
    override fun convert(holder: DataBindBaseViewHolder, item: AppBaseListResponse.BaseListBean) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemWatchRegistrationBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        val tvSignPeopleSearch = holder.getView<AppCompatTextView>(R.id.tvSignPeopleSearch)
        val tvGroupProcedure = holder.getView<AppCompatTextView>(R.id.tvGroupProcedure)
        tvSignPeopleSearch.paint.flags = Paint.UNDERLINE_TEXT_FLAG
        tvGroupProcedure.paint.flags = Paint.UNDERLINE_TEXT_FLAG

        holder.setGone(R.id.tvItemPassSignUploadProof, item.status == 1)


        var state = ""
        var backgroundId = 0
        var colorId = 0
        when (item.status) {//状态 1-未开始 2-进行中 3-已结束
            1 -> {
                state = "未开始"
                backgroundId = R.drawable.round_btn_gray10_bg
                colorId = ContextCompat.getColor(context, R.color.comm_text_gray_light)
            }

            2 -> {
                state = "进行中"
                backgroundId = R.drawable.round_btn_5a5a5a_5radiu_bg
                colorId = ContextCompat.getColor(context, R.color.white)
            }

            else -> {
                state = "已结束"
                backgroundId = R.drawable.round_btn_gray10_bg
                colorId = ContextCompat.getColor(context, R.color.comm_text_gray_light)
            }
        }
        holder.setText(R.id.tvGroupState, state)
        holder.setBackgroundResource(R.id.tvGroupState, backgroundId)
        holder.setTextColor(R.id.tvGroupState, colorId)
    }
}